package com.info33.platform.system.dic.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.annotation.JsonView;
import com.info33.platform.common.mvc.controller.BaseController;
import com.info33.platform.common.mvc.vo.Result;
import com.info33.platform.system.dic.dto.SysDicModDTO;
import com.info33.platform.system.dic.entity.SysDicMod;
import com.info33.platform.system.dic.service.SysDicModService;
import com.info33.platform.system.dic.vo.SysDicModVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 系统 - 字典 v2 模块管理
 *
 * @author nyj2one
 * @since 2022-11-30 15:15:11
 */
@RestController
@RequestMapping("/SysDicMod")
@Api(tags = "系统 - 字典 v2 模块管理")
public class SysDicModController extends BaseController<SysDicModService, SysDicMod> {

    private final SysDicModService sysDicModService;

    @Autowired
    public SysDicModController(SysDicModService sysDicModService) {
        super(sysDicModService);
        this.sysDicModService = sysDicModService;
    }

    /*
     * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     *
     * PC 端 api
     *
     * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     */

    @PostMapping(value = "/pc/page/{pageNum}/{pageSize}")
    @ApiOperation(value = "pc 分页", notes = "-1-1 查询全部", hidden = true)
    public Result<IPage<SysDicModVO>> pcPage(
            @RequestBody SysDicModDTO dto,
            @PathVariable int pageNum,
            @PathVariable int pageSize) {
        return Result.ok(sysDicModService.pcPage(new Page<>(pageNum, pageSize), dto));
    }

    @GetMapping(value = "/pc/tree/{modIndex}")
    @ApiOperation(value = "pc 树结构")
    @JsonView(SysDicModVO.PcTreeByIndexes.class)
    public Result<SysDicModVO> pcTreeByIndexes(
            @PathVariable String modIndex) {
        return Result.ok(sysDicModService.pcTreeByIndexes(modIndex));
    }

}
